package testDemo.IOStream.Properties;

import java.io.*;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws IOException {
        //将集合存入文件
        myStore();
        //将文件读入集合
        myLoad();
    }

    private static void myLoad() throws IOException {
        Properties p = new Properties();
        BufferedReader br = new BufferedReader(new FileReader("a.txt"));
        p.load(br);
        System.out.println(p);
    }

    private static void myStore() throws IOException {
        Properties p = new Properties();
        p.setProperty("张三","19");
        p.setProperty("李四","20");
        p.setProperty("王五","18");

        PrintWriter pw=new PrintWriter(new FileWriter("a.txt"),true);
        p.store(pw,null);
    }
}
